import { _decorator, Label } from 'cc';
import { UIComponent } from '../../../Framework/Scripts/Managers/UIComponent';
const { ccclass } = _decorator;

@ccclass('ExitTip_Ctr')
export class ExitTip_Ctr extends UIComponent {
    des: any;
    leftCall: Function = null;
    rightCall: Function = null;
    protected onLoad(): void {
        this.AddOpenAni(this.ViewNode('root'));
        this.InitUI();
    }

    start() {
        this.InitData();
    }

    protected onDestroy(): void {
        this.unRegisterEvent();
    }

    private InitUI(){
        this.registerEvent();

        this.des = this.ViewComponent('root/Label',Label);

        this.AddButtonListener('root/btn1',this,this.OnBtn1Click);
        this.AddButtonListener('root/btn2',this,this.OnBtn2Click);
    }

    private InitData(){
        // this.leftCall = null;
        // this.rightCall = null;
    }

    private registerEvent(){
        // director.on(EventMsgKes.loading,this.onLoadingPro,this);
    }

    private unRegisterEvent(){
        // director.off(EventMsgKes.loading,this.onLoadingPro,this);
    }

    private OnBtn1Click(){
        this.leftCall &&  this.leftCall();
        this.node.destroy()
    }
    
    private OnBtn2Click(){
        this.rightCall &&  this.rightCall();
        this.node.destroy()
    }

    public setData(callLeft:Function, calllRigth: Function, des: string){
        this.leftCall = callLeft;
        this.rightCall = calllRigth;
        this.des.string = des;
    }
}